#include <bits/stdc++.h>
#include<unordered_set>

#define ll long long
#define ull unsigned long long
#define uint unsigned int

#define YES cout << "YES" << '\n'
#define NO cout << "NO" << '\n'
#define endl '\n'
const int INF = 1e9;
const int MOD = 998244353;
using namespace std;

/*思考

*/
ll ans = 0;
ll sum = 0;
int nums[25] = { 0 };
int N, k;
bool check(int a) {
    if (a <= 3) {
        return a > 1;
    }
    for (int i = 2; i*i <= a; i++) {
        if (a % i == 0) {
            return false;
        }
    }
    return true;
}
void dfs(int n,int x) {//n表示第几个数，x表示已经选了几个数
    if (x == k) {
        if (check(sum)) {
            ++ans;
        }
        return;
    }
    if (n > N) return; //防止越界

    dfs(n+1,x);//不取这个数,直接进入下一个数
    sum += nums[n];
    dfs(n + 1,x+1);
    sum -= nums[n];//恢复
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> k;
    for (int i = 1; i <= N; i++) {
        cin >> nums[i];
    }
    dfs(1,0);
    cout << ans << endl;
    
    return 0;
}